package Work;

import java.util.Scanner;
class IdException extends Exception {
    @Override
    public void printStackTrace() {
        System.out.println("用户名或密码错误！");
    }
}
public class t2 {
    public static void main(String[] args) {
        try {
            Scanner scan = new Scanner(System.in);
            System.out.println("请输入用户名->");
            String name = scan.next();
            System.out.println("请输入密码->");
            String id = scan.next();
            if((!name.equals("张三"))||(!id.equals("123456"))) {
                throw new IdException();
            }
        } catch (IdException e) {
            e.printStackTrace();
            return;
        }
        System.out.println("登录成功！");
    }
}
